# from link import list
from threading import Lock, Thread, Condition

lock = Lock()
condition = Condition(lock)
l = list()


def consumer(*args, **kwargs):
    while True:
        condition.acquire()
        if l:
        #     for i in range(len(l)):
            data = l.pop()
            print('\n' + data)
        else:
            condition.wait()
        condition.release()


def worker():
    while True:
        data = input('please input data:')
        condition.acquire()

        l.append(data)
        condition.notify()
        condition.release()

consume_thread1 = Thread(target=consumer, )
consume_thread2 = Thread(target=worker, )
consume_thread1.start()
consume_thread2.start()
consume_thread1.join()
consume_thread2.join()


